The Use of query string in web application
We pass the value from one page to another page by query string, we write the syntax as
1) Response.Redirect("Default.aspx?query=John Smith");
where "query" is query string variable and "John Smith" is the string value for query variable.
Now we access the value on Default.aspx page as
string query=Request.QueryString["query"].toString();
2) we pass the multiple parameter by query string then we write the syntax as
Response.Redirect("Default.aspx?query1=John Smith &query2=krish");
Now we access the value on Default.aspx page as
string query1=Request.QueryString["query1"].toString();
string query2=Request.QueryString["query2"].toString();
or
string query1=Request.QueryString[0].toString();
string query2=Request.QueryString[1].toString();
or
string query1=Request.Params[0].toString();
string query2=Request.Params[1].toString();
3) We pass the any value by query string as
string str="JohnSmith";
Response.Redirect("Default.aspx?query="+str);
And access these value on another page by
string query=Request.QueryString["query"].toString();
Advantage of query string
it is easy to create for passing data from one page to another
Disadvantage
It is visible in url
It contains high lenth data so it is not support to sending more data
Anonymous User
31-Jan-2019It is Very helpful.
Manish Kumar
13-Jun-2017It was really helpful to read this post.